package service.impl;

import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.github.miemiedev.mybatis.paginator.domain.Paginator;

import dao.ReportMapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import model.Report;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import service.ReportService;

@Service
@SuppressWarnings("rawtypes")
public class ReportServiceImpl implements ReportService {

	@Autowired
	private ReportMapper reportDAO;

	public List<Report> findReportList(HashMap<String, Object> xmap) {
		return this.reportDAO.findReportList(xmap);
	}

	public int addValue(Report report) {
		return this.reportDAO.addValue(report);
	}

	public List<Report> selectByPrimaryKey(Map map) {
		return this.reportDAO.selectByPrimaryKey(map);
	}

	@SuppressWarnings("unchecked")
	public Map<String, Object> selectAll(PageBounds pageBounds, Map mapValue) {
		List reportList = this.reportDAO.selectAll(pageBounds, mapValue);
		Map map = new HashMap();
		if (reportList.size() > 0) {
			PageList pageOrders = (PageList) reportList;

			Paginator paginator = pageOrders.getPaginator();
			map.put("list", pageOrders);
			map.put("paginator", paginator);
		}
		return map;
	}

	public int update(Report report) {
		return this.reportDAO.update(report);
	}

	public void delete(Long rid) {
		this.reportDAO.delete(rid);
	}

	public Report selectById(Long rid) {
		return this.reportDAO.selectById(rid);
	}
}